package org.dromara.resource.api.feign;

import org.dromara.common.core.domain.R;
import org.dromara.resource.api.domain.RemoteFile;
import org.dromara.resource.api.feign.fallback.ResourceFileFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

import static org.dromara.common.core.constant.ServerNameConstants.RESOURCE_SERVER_NAME;

/**
 * @author: zhou shuai
 * @date: 2024/10/5 15:35
 * @version: v1
 */
@FeignClient(contextId = "resource-file-api", name = RESOURCE_SERVER_NAME, fallbackFactory = ResourceFileFallBack.class)
public interface ResourceFileClient {

    /**
     * 文件上传请求
     */
    @PostMapping(value = "/api/resource/file/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<RemoteFile> fileUpload(@RequestPart("avatarfile") MultipartFile avatarfile);

    /**
     * 通过ossId查询对应的url
     *
     * @param ossIds ossId串逗号分隔
     * @return url串逗号分隔
     */
    @GetMapping("/api/resource/file/url/byOssIds")
    R<String> getFileUrlByOssIds(@RequestParam("ossIds") String ossIds);

    /**
     * 通过ossId查询列表
     *
     * @param ossIds ossId串逗号分隔
     * @return 列表
     */
    @GetMapping("/api/resource/file/list/byOssIds")
    R<List<RemoteFile>> getFileListByOssIds(@RequestParam("ossIds") String ossIds);

}
